package com.cskaoyan.mall.search.converter;

import com.cskaoyan.mall.dto.ItemDto;
import com.cskaoyan.mall.dto.ProductDto;
import com.cskaoyan.mall.search.entity.ItemDocument;
import com.cskaoyan.mall.search.entity.ItemDocumentStandardText;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface ProductConverter {

    @Mappings({
            @Mapping(source = "id",target = "productId"),
            @Mapping(source = "title",target = "productName"),
            @Mapping(source = "price",target = "salePrice"),
            @Mapping(source = "sellPoint",target = "subTitle"),
            @Mapping(source = "image",target = "picUrl")
    })
    ProductDto item2Dto(ItemDocument item);

    @Mappings({
            @Mapping(source = "id",target = "productId"),
            @Mapping(source = "title",target = "productName"),
            @Mapping(source = "price",target = "salePrice"),
            @Mapping(source = "sellPoint",target = "subTitle"),
            @Mapping(source = "image",target = "picUrl")
    })
    ProductDto itemStandards2Dto(ItemDocumentStandardText item);

    List<ProductDto> items2Dto(List<ItemDocument> items);

    ItemDocument item2Document(ItemDto item);

    List<ItemDocument> items2Documents(List<ItemDto> items);
}
